class TaskManager:
    def __init__(self, filename="tasklist.txt"):
        self.filename = filename
        self.task_list = []
        self.load_tasks()

    def load_tasks(self):
        try:
            with open(self.filename, "r") as taskfile:
                for line in taskfile:
                    if line.strip():
                        self.task_list.append(line.strip().split(' | '))
        except FileNotFoundError:
            pass

    def add_task(self, priority, description, date, task):
        with open(self.filename, 'a') as taskfile:
            taskfile.write(f"{priority} | {description} | {date} | {task}\n")
        self.task_list.append((priority, description, date, task))

    def delete_task(self, index):
        if 0 <= index < len(self.task_list):
            del self.task_list[index]
            with open(self.filename, 'w') as taskfile:
                for t in self.task_list:
                    taskfile.write(f"{t[0]} | {t[1]} | {t[2]} | {t[3]}\n")

    def edit_task(self, index, priority, description, date, task):
        if 0 <= index < len(self.task_list):
            self.task_list[index] = (priority, description, date, task)
            with open(self.filename, 'w') as taskfile:
                for t in self.task_list:
                    taskfile.write(f"{t[0]} | {t[1]} | {t[2]} | {t[3]}\n")

    def get_tasks(self):
        return [f"{t[0]} | {t[1]} | {t[2]} | {t[3]}" for t in self.task_list]